var customerShare = function(){

	var ps = new ProjectSourceDemo();
	var thiz=this;
	
	var searchID = new Ext.form.TextField({
		fieldLabel : '合同编号',
		width : 150
	});
	var searchName = new Ext.form.TextField({
		fieldLabel : '合同名称',
		width : 150
	});
	
	var searchArea = new Ext.form.ComboBox( {
		fieldLabel : '所属区域',
		//hiddenName : 'type',
		store: OMS.AREA,
		mode : 'local',
		displayField : 'name',
		triggerAction : 'all',
		editable : false,
		valueField : 'id',
		typeAhead : true,
		width : 150,
		emptyText : '---请选择---',
		selectOnFocus : true
	});
	
	var btn_search = new Ext.Button({
		text : '查询',
		iconCls: 'icon-search',
		handler: function (){
			pactStore.load();
			}
	});
	var pactStore = new Ext.data.JsonStore(
			{
				url : '../pact/searchPact.form?status=10&timesnap=' + new Date().getTime(),
				root : 'result',
				fields : [  'pactID', 'customerID', 'customerArea',
							'pactType', 'pactMoney', 'pactRemark',
							'pactSuccessName', 'pactMoneyType', 'pactName', 'pactEndDate',
							'pactStartDate', 'pactSuccessDate', 'CreateBy', 'CreateTime','LastUpdateBy',
							'LastUpdateDate', 'pactstage', 'customerName'],
				listeners : {
					scope : this,
					beforeload : function(thiz) {
						thiz.baseParams = {
							searchName : searchName.getValue(),
							pactstage:0
							
						};
					}
				}
			});
	
	var xg = Ext.grid
	var sm = new xg.CheckboxSelectionModel();
	var createGrid = new Ext.grid.GridPanel({
		sm: sm,
		width : 930,
		height : 250,
		store : pactStore,
		scope : this,
		listeners : {
			scope : this,
			rowmousedown : function(grid,index,e){
				var data = grid.store.getAt(index).data;
				ps.setPactValue(data);
		       
			}
		},
		columns : [ sm,
					{header:'合同名称',width: 150,sortable: true,dataIndex:'pactName'},
					{header:'客户名称',width: 150,sortable: true,dataIndex:'customerName'},
			        {header:'状态',width: 100, sortable: true,dataIndex:'pactstage',renderer:function(value){return OMS.PACTSTAGE[value];}},
			        {header:'合同类型',dataIndex:'pactType',renderer:function(value,row){return OMS.PACTTYPE[value];}},
			        {header:'签约人',dataIndex:'pactSuccessName'},
			        {header:'签约日期',width: 170,dataIndex:'pactSuccessDate'}],
       bbar:new Ext.PagingToolbar({
		 pageSize: 5,
         store: pactStore,
         displayInfo: true,
         displayMsg: '显示第 {0} 条到 {1} 条记录，一共 {2} 条',
         emptyMsg: "没有记录..."
       })
	});
	
	
	this.customerSharePanel = new Ext.form.FormPanel({
		frame : true,
		width : 950,
		fileUpload: true, 
		labelWidth : 85,
		buttons : [{text:'缔结',iconCls: 'icon-accept',scope:this,handler:function(){
			           var scope=this;
							Utils.confirm2({
							msg:"是否选择缔结下列合同？",
							width:220,
								fn:function(){
									var count=createGrid.getSelectionModel().getSelections();
									var ids="";
									if(count<=0){//这里 的逻辑 按照网格里的数据判断的
										alert("请选择数据");
										return false;}
									for(var i=0 ;i<count.length;i++){
										var data = count[i].data['pactID'];
										ids+=count[i].data['pactID']+',';
									}
									scope.customerSharePanel.getForm().submit({
										waitTitle : '系统提示',
										waitMsg : '数据提交中，请稍候...',
										url:'../pact/djPact.form?timesnap=' + new Date().getTime()+'&ids='+ids,
										method:'post',
										success:function(data){
											Utils.info("操作成功","系统提示");	
											pactStore.load();
												}
										});
		           					}
		           				})
		           			}
		           	}],
			items : [{layout:'column',defaults:{layout:'form'},
			      items:[{columnWidth:0.3,items:[searchName]},
			             {columnWidth:0.15,items:[btn_search]}
			             
			             ]
				},createGrid],
	   listeners: {
	    	render: {fn:function(){ 
					pactStore.load();
			}}
		}
	});
	


}